package raspberry_pi_app;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import bradz.media_server.raspberry_pi_app.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ToggleButton;

public class ActivityMain extends Activity{
	
	private ClassUberLogger logger;
	private ApplicationGlobalVars globals;
	private ClassNetworkHelper helper;
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	    setContentView(R.layout.activity_main);
	    logger = new ClassUberLogger("ActivityMain");
	    globals = ((ApplicationGlobalVars) this.getApplication());
	    helper = new ClassNetworkHelper(this,globals);
	    init_buttons();
	}
	
	public void init_buttons(){
		
		Button slideshow_toggle = (Button) findViewById(R.id.slideshow_toggle);
		slideshow_toggle.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				List<NameValuePair> pairs = new ArrayList<NameValuePair>();
				pairs.add(new BasicNameValuePair("payload", globals.get_developer_payload()));
        		pairs.add(new BasicNameValuePair("slideshow", "toggle"));
        		helper.send_message(pairs,"settings/");
			}
		});
		
		Button fullscreen_toggle = (Button) findViewById(R.id.full_screen_toggle);
		fullscreen_toggle.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				List<NameValuePair> pairs = new ArrayList<NameValuePair>();
				pairs.add(new BasicNameValuePair("payload", globals.get_developer_payload()));
        		pairs.add(new BasicNameValuePair("full_screen", "toggle"));
        		helper.send_message(pairs,"settings/");
			}
		});
		
		Button media_button = (Button) findViewById(R.id.navigate_media);
		media_button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	logger.info("Media button clicked");
            	Intent myIntent = new Intent(getBaseContext(), ActivityMedia.class);
        		startActivity(myIntent);
            }
        });
		
		Button message_button = (Button) findViewById(R.id.navigate_message);
		message_button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	logger.info("Message button clicked");
            	Intent myIntent = new Intent(getBaseContext(), ActivityMessage.class);
        		startActivity(myIntent);
            }
        });
		
		Button image_button = (Button) findViewById(R.id.navigate_image);
		image_button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	logger.info("Image button clicked");
            	Intent myIntent = new Intent(getBaseContext(), ActivityPicture.class);
        		startActivity(myIntent);
            }
        });
	}
}
